import re

if __name__ == '__main__':
    patterns = ['this', 'that']
    text = 'Does this text match the pattern?'

    regexes = []
    for pattern in patterns:
        # re.compile 编译正则表达式，后续可以加快正则匹配的速度
        regexes.append(re.compile(pattern=pattern))

    for regex in regexes:
        print('Seeking "{}" ->'.format(regex.pattern), end=' ')
        match = regex.search(text)

        if match is not None:
            print(match)
            # 匹配正则表达式在字符串的起始位置
            print(match.start())
            # 匹配正则表达式在字符串的结束位置
            print(match.end())
            # 匹配正则表达式在字符串的位置（起始和结束）
            print(match.span())

            # search 返回对象不使用
            # print(match.groups(0))
            # print(match.groupdict())

        else:
            print("没有匹配结果")
